Get Data

Connect to the database

load(file = "./connectionInfo.RData")

con <- DBI::dbConnect(drv = RPostgreSQL::PostgreSQL(),
                      dbname = db,
                      host = host,
                      port = port,
                      user = user,
                      password = password)

# DBI::dbGetQuery(conn = con,
#                 statement = "SELECT * FROM sensor_data WHERE type = 'Air Humidity' LIMIT 10")

measures <- DBI::dbGetQuery(conn = con,
                            statement = "SELECT * FROM sensor_data") %>%
  tidyr::drop_na(data = .,type)

DBI::dbDisconnect(conn = con)
## [1] TRUE

Including Plots

You can also embed plots, for example:

time type measurementId measurementValue
2023-11-03 06:15:33 Air Humidity 4098 99.000
2023-11-03 06:00:27 Air Humidity 4098 99.000
2023-11-03 05:45:21 Air Humidity 4098 99.000
2023-11-03 05:30:14 Air Humidity 4098 99.000
2023-11-03 05:15:08 Air Humidity 4098 99.000
2023-11-03 05:00:02 Air Humidity 4098 99.000
2023-11-03 04:44:55 Air Humidity 4098 99.000
2023-11-03 04:29:49 Air Humidity 4098 99.000
2023-11-03 04:14:43 Air Humidity 4098 99.000
2023-11-03 03:59:36 Air Humidity 4098 99.000
2023-11-03 06:15:33 Air Temperature 4097 11.900
2023-11-03 06:00:27 Air Temperature 4097 11.800
2023-11-03 05:45:21 Air Temperature 4097 12.000
2023-11-03 05:30:14 Air Temperature 4097 11.800
2023-11-03 05:15:08 Air Temperature 4097 11.600
2023-11-03 05:00:02 Air Temperature 4097 11.600
2023-11-03 04:44:55 Air Temperature 4097 11.900
2023-11-03 04:29:49 Air Temperature 4097 12.100
2023-11-03 04:14:43 Air Temperature 4097 12.300
2023-11-03 03:59:36 Air Temperature 4097 12.400
2023-11-03 06:15:33 Barometric Pressure 4101 97930.000
2023-11-03 06:00:27 Barometric Pressure 4101 97940.000
2023-11-03 05:45:21 Barometric Pressure 4101 97940.000
2023-11-03 05:30:14 Barometric Pressure 4101 97940.000
2023-11-03 05:15:08 Barometric Pressure 4101 97950.000
2023-11-03 05:00:02 Barometric Pressure 4101 97950.000
2023-11-03 04:44:55 Barometric Pressure 4101 97970.000
2023-11-03 04:29:49 Barometric Pressure 4101 98000.000
2023-11-03 04:14:43 Barometric Pressure 4101 97970.000
2023-11-03 03:59:36 Barometric Pressure 4101 98000.000
2023-11-03 06:15:33 Light Intensity 4099 431.000
2023-11-03 06:00:27 Light Intensity 4099 108.000
2023-11-03 05:45:21 Light Intensity 4099 0.000
2023-11-03 05:30:14 Light Intensity 4099 0.000
2023-11-03 05:15:08 Light Intensity 4099 0.000
2023-11-03 05:00:02 Light Intensity 4099 0.000
2023-11-03 04:44:55 Light Intensity 4099 0.000
2023-11-03 04:29:49 Light Intensity 4099 0.000
2023-11-03 04:14:43 Light Intensity 4099 0.000
2023-11-03 03:59:36 Light Intensity 4099 0.000
2023-11-03 06:15:33 Rain Gauge 4113 0.000
2023-11-03 06:00:27 Rain Gauge 4113 0.000
2023-11-03 05:45:21 Rain Gauge 4113 0.000
2023-11-03 05:30:14 Rain Gauge 4113 0.000
2023-11-03 05:15:08 Rain Gauge 4113 0.000
2023-11-03 05:00:02 Rain Gauge 4113 0.000
2023-11-03 04:44:55 Rain Gauge 4113 0.000
2023-11-03 04:29:49 Rain Gauge 4113 0.000
2023-11-03 04:14:43 Rain Gauge 4113 1.524
2023-11-03 03:59:36 Rain Gauge 4113 1.524
2023-11-03 06:15:33 UV Index 4190 0.000
2023-11-03 06:00:27 UV Index 4190 0.000
2023-11-03 05:45:21 UV Index 4190 0.000
2023-11-03 05:30:14 UV Index 4190 0.000
2023-11-03 05:15:08 UV Index 4190 0.000
2023-11-03 05:00:02 UV Index 4190 0.000
2023-11-03 04:44:55 UV Index 4190 0.000
2023-11-03 04:29:49 UV Index 4190 0.000
2023-11-03 04:14:43 UV Index 4190 0.000
2023-11-03 03:59:36 UV Index 4190 0.000
2023-11-03 06:15:33 Wind Direction Sensor 4104 112.000
2023-11-03 06:00:27 Wind Direction Sensor 4104 112.000
2023-11-03 05:45:21 Wind Direction Sensor 4104 112.000
2023-11-03 05:30:14 Wind Direction Sensor 4104 112.000
2023-11-03 05:15:08 Wind Direction Sensor 4104 112.000
2023-11-03 05:00:02 Wind Direction Sensor 4104 112.000
2023-11-03 04:44:55 Wind Direction Sensor 4104 112.000
2023-11-03 04:29:49 Wind Direction Sensor 4104 112.000
2023-11-03 04:14:43 Wind Direction Sensor 4104 112.000
2023-11-03 03:59:36 Wind Direction Sensor 4104 112.000
2023-11-03 06:15:33 Wind Speed 4105 0.000
2023-11-03 06:00:27 Wind Speed 4105 0.000
2023-11-03 05:45:21 Wind Speed 4105 0.000
2023-11-03 05:30:14 Wind Speed 4105 0.000
2023-11-03 05:15:08 Wind Speed 4105 0.000
2023-11-03 05:00:02 Wind Speed 4105 0.000
2023-11-03 04:44:55 Wind Speed 4105 0.000
2023-11-03 04:29:49 Wind Speed 4105 0.000
2023-11-03 04:14:43 Wind Speed 4105 0.000
2023-11-03 03:59:36 Wind Speed 4105 0.000
p <- measures %>%
  dplyr::filter(type == "Air Humidity") %>%
ggplot2::ggplot(data = .) +
  ggplot2::geom_point(ggplot2::aes(x = time, y = measurementValue))

plotly::ggplotly(p = p)